from easygui import EgStore


# 定义一个名为Settings的类，继承自Egstore类
class Settings(EgStore):

    def __init__(self, filename): # 需要指定文件名
        # 指定要记住的属性名称
        self.author = ""
        self.book = ""

        # 必须执行下面两个语句
        self.filename = filename
        self.restore()


# 创建Settings的实例化对象settings
settings_file_name = "settings.txt"
settings = Settings(settings_file_name)
author = "小甲鱼"
book = "《零基础入门学习Python》"

# 将上面两个变量的值保存到settings对象中
settings.author = author
settings.book = book
settings.store()
print("保存完毕")

if __name__ == "__main__":
    settings_file_name = "settings.txt"
    settings = Settings(settings_file_name)
    print(settings.author)